package org.gap.web.jsf;

import java.util.List;

import org.gap.dao.CodesPostauxDAO;
import org.gap.dao.EtablissementsBancairesDAO;
import org.gap.dao.PaysDAO;

import org.gap.domain.CodesPostaux;
import org.gap.domain.EtablissementsBancaires;
import org.gap.domain.Pays;

import org.gap.service.PaysService;

import org.springframework.beans.factory.annotation.Autowired;

import org.springframework.context.annotation.Scope;

import org.springframework.stereotype.Component;

import org.springframework.transaction.annotation.Transactional;

/**
 * Spring Component that handles CRUD requests for Pays entities
 * 
 */
@Scope("session")
@Component("PaysComponent")
public class PaysComponentImpl implements PaysComponent {

	/**
	 * Data type variable that provides CRUD operations for Pays entities
	 * 
	 */
	private Pays pays;

	/**
	 * DAO injected by Spring that manages EtablissementsBancaires entities
	 * 
	 */
	private EtablissementsBancaires etablissementsbancaireses;

	/**
	 * DAO injected by Spring that manages CodesPostaux entities
	 * 
	 */
	private CodesPostaux codespostauxes;

	/**
	 * DAO injected by Spring that manages CodesPostaux entities
	 * 
	 */
	@Autowired
	private CodesPostauxDAO codesPostauxDAO;

	/**
	 * DAO injected by Spring that manages EtablissementsBancaires entities
	 * 
	 */
	@Autowired
	private EtablissementsBancairesDAO etablissementsBancairesDAO;

	/**
	 * DAO injected by Spring that manages Pays entities
	 * 
	 */
	@Autowired
	private PaysDAO paysDAO;

	/**
	 * Service injected by Spring that provides CRUD operations for Pays entities
	 * 
	 */
	@Autowired
	private PaysService paysService;

	/** 
	 */
	public PaysComponentImpl() {
	}

	/**
	 * Select the child CodesPostaux entity for display allowing the user to confirm that they would like to delete the entity
	 * 
	 */
	@Transactional
	public String confirmDeletePaysCodesPostauxes(String pays_pppPays, String related_codespostauxes_cdpPays, String related_codespostauxes_cdpCodePostal, String related_codespostauxes_cdpNInsee, String related_codespostauxes_cdpLocalite) {
		codespostauxes = codesPostauxDAO.findCodesPostauxByPrimaryKey(related_codespostauxes_cdpPays, related_codespostauxes_cdpCodePostal, related_codespostauxes_cdpNInsee, related_codespostauxes_cdpLocalite);

		return "/jsf/pays/codespostauxes/deleteCodesPostauxes.xhtml";
	}

	/**
	 * Save an existing Pays entity
	 * 
	 */
	@Transactional
	public String savePays(Pays pays) {
		paysService.savePays(pays);
		return "/jsf/pays/listPayss.xhtml";
	}

	/**
	 * Show all EtablissementsBancaires entities by Pays
	 * 
	 */
	@Transactional
	public List<EtablissementsBancaires> listPaysEtablissementsBancaireses(String pppPaysKey) {
		return new java.util.ArrayList<EtablissementsBancaires>(paysDAO.findPaysByPrimaryKey(pppPaysKey).getEtablissementsBancaireses());
	}

	/**
	 * Edit an existing Pays entity
	 * 
	 */
	@Transactional
	public String editPays(String pppPaysKey) {
		pays = paysDAO.findPaysByPrimaryKey(pppPaysKey);

		return "/jsf/pays/editPays.xhtml";
	}

	/**
	 * Delete an existing Pays entity
	 * 
	 */
	@Transactional
	public String deletePays(String pppPaysKey) {
		Pays pays = paysDAO.findPaysByPrimaryKey(pppPaysKey);
		paysService.deletePays(pays);
		return "/jsf/pays/listPayss.xhtml";
	}

	/**
	 * Getter for variable Pays
	 * 
	 */
	@Transactional
	public Pays getPays() {
		return pays;
	}

	/**
	 * Select the Pays entity for display allowing the user to confirm that they would like to delete the entity
	 * 
	 */
	@Transactional
	public String confirmDeletePays(String pppPaysKey) {
		pays = paysDAO.findPaysByPrimaryKey(pppPaysKey);

		return "/jsf/pays/deletePays.xhtml";
	}

	/**
	 * Getter for variable Pays
	 * 
	 */
	@Transactional
	public EtablissementsBancaires getEtablissementsbancaireses() {
		return etablissementsbancaireses;
	}

	/**
	 * Edit an existing CodesPostaux entity
	 * 
	 */
	@Transactional
	public String editPaysCodesPostauxes(String pays_pppPays, String related_codespostauxes_cdpPays, String related_codespostauxes_cdpCodePostal, String related_codespostauxes_cdpNInsee, String related_codespostauxes_cdpLocalite) {
		codespostauxes = codesPostauxDAO.findCodesPostauxByPrimaryKey(related_codespostauxes_cdpPays, related_codespostauxes_cdpCodePostal, related_codespostauxes_cdpNInsee, related_codespostauxes_cdpLocalite, -1, -1);
		return "/jsf/pays/codespostauxes/editCodesPostauxes.xhtml";
	}

	/**
	 * Save an existing EtablissementsBancaires entity
	 * 
	 */
	@Transactional
	public String savePaysEtablissementsBancaireses(String pays_pppPays, EtablissementsBancaires etablissementsbancaires) {
		pays = paysService.savePaysEtablissementsBancaireses(pays_pppPays, etablissementsbancaires);

		return "/jsf/pays/viewPays.xhtml";
	}

	/**
	 * Getter for variable Pays
	 * 
	 */
	@Transactional
	public CodesPostaux getCodespostauxes() {
		return codespostauxes;
	}

	/**
	 * View an existing CodesPostaux entity
	 * 
	 */
	@Transactional
	public String selectPaysCodesPostauxes(String pays_pppPays, String related_codespostauxes_cdpPays, String related_codespostauxes_cdpCodePostal, String related_codespostauxes_cdpNInsee, String related_codespostauxes_cdpLocalite) {
		codespostauxes = codesPostauxDAO.findCodesPostauxByPrimaryKey(related_codespostauxes_cdpPays, related_codespostauxes_cdpCodePostal, related_codespostauxes_cdpNInsee, related_codespostauxes_cdpLocalite, -1, -1);
		return "/jsf/pays/codespostauxes/viewCodesPostauxes.xhtml";
	}

	/**
	 * Show all CodesPostaux entities by Pays
	 * 
	 */
	@Transactional
	public List<CodesPostaux> listPaysCodesPostauxes(String pppPaysKey) {
		return new java.util.ArrayList<CodesPostaux>(paysDAO.findPaysByPrimaryKey(pppPaysKey).getCodesPostauxes());
	}

	/**
	 * Select an existing Pays entity
	 * 
	 */
	@Transactional
	public String selectPays(String pppPaysKey) {
		pays = paysDAO.findPaysByPrimaryKey(pppPaysKey);

		return "/jsf/pays/viewPays.xhtml";
	}

	/**
	 * Delete an existing CodesPostaux entity
	 * 
	 */
	@Transactional
	public String deletePaysCodesPostauxes(String pays_pppPays, String related_codespostauxes_cdpPays, String related_codespostauxes_cdpCodePostal, String related_codespostauxes_cdpNInsee, String related_codespostauxes_cdpLocalite) {
		pays = paysService.deletePaysCodesPostauxes(pays_pppPays, related_codespostauxes_cdpPays, related_codespostauxes_cdpCodePostal, related_codespostauxes_cdpNInsee, related_codespostauxes_cdpLocalite);

		return "/jsf/pays/viewPays.xhtml";
	}

	/**
	 * Select the child EtablissementsBancaires entity for display allowing the user to confirm that they would like to delete the entity
	 * 
	 */
	@Transactional
	public String confirmDeletePaysEtablissementsBancaireses(String pays_pppPays, String related_etablissementsbancaireses_etbPays, Integer related_etablissementsbancaireses_etbEtablissement) {
		etablissementsbancaireses = etablissementsBancairesDAO.findEtablissementsBancairesByPrimaryKey(related_etablissementsbancaireses_etbPays, related_etablissementsbancaireses_etbEtablissement);

		return "/jsf/pays/etablissementsbancaireses/deleteEtablissementsBancaireses.xhtml";
	}

	/**
	 * Edit an existing EtablissementsBancaires entity
	 * 
	 */
	@Transactional
	public String editPaysEtablissementsBancaireses(String pays_pppPays, String related_etablissementsbancaireses_etbPays, Integer related_etablissementsbancaireses_etbEtablissement) {
		etablissementsbancaireses = etablissementsBancairesDAO.findEtablissementsBancairesByPrimaryKey(related_etablissementsbancaireses_etbPays, related_etablissementsbancaireses_etbEtablissement, -1, -1);
		return "/jsf/pays/etablissementsbancaireses/editEtablissementsBancaireses.xhtml";
	}

	/**
	 * View an existing EtablissementsBancaires entity
	 * 
	 */
	@Transactional
	public String selectPaysEtablissementsBancaireses(String pays_pppPays, String related_etablissementsbancaireses_etbPays, Integer related_etablissementsbancaireses_etbEtablissement) {
		etablissementsbancaireses = etablissementsBancairesDAO.findEtablissementsBancairesByPrimaryKey(related_etablissementsbancaireses_etbPays, related_etablissementsbancaireses_etbEtablissement, -1, -1);
		return "/jsf/pays/etablissementsbancaireses/viewEtablissementsBancaireses.xhtml";
	}

	/**
	 * Delete an existing EtablissementsBancaires entity
	 * 
	 */
	@Transactional
	public String deletePaysEtablissementsBancaireses(String pays_pppPays, String related_etablissementsbancaireses_etbPays, Integer related_etablissementsbancaireses_etbEtablissement) {
		pays = paysService.deletePaysEtablissementsBancaireses(pays_pppPays, related_etablissementsbancaireses_etbPays, related_etablissementsbancaireses_etbEtablissement);

		return "/jsf/pays/viewPays.xhtml";
	}

	/**
	 * Create a new EtablissementsBancaires entity
	 * 
	 */
	@Transactional
	public String newPaysEtablissementsBancaireses(String pays_pppPays) {
		etablissementsbancaireses = new EtablissementsBancaires();

		return "/jsf/pays/etablissementsbancaireses/createEtablissementsBancaireses.xhtml";
	}

	/**
	 * Create a new CodesPostaux entity
	 * 
	 */
	@Transactional
	public String newPaysCodesPostauxes(String pays_pppPays) {
		codespostauxes = new CodesPostaux();

		return "/jsf/pays/codespostauxes/createCodesPostauxes.xhtml";
	}

	/**
	 * Create a new Pays entity
	 * 
	 */
	@Transactional
	public String newPays() {
		pays = new Pays();

		return "/jsf/pays/createPays.xhtml";
	}

	/**
	 * Show all Pays entities
	 * 
	 */
	@Transactional
	public List<Pays> listPayss() {
		return new java.util.ArrayList<Pays>(paysService.loadPayss());
	}

	/**
	 * Save an existing CodesPostaux entity
	 * 
	 */
	@Transactional
	public String savePaysCodesPostauxes(String pays_pppPays, CodesPostaux codespostaux) {
		pays = paysService.savePaysCodesPostauxes(pays_pppPays, codespostaux);

		return "/jsf/pays/viewPays.xhtml";
	}

}
